package com.shenmazong.controller;

import com.shenmazong.service.TbAdminService;
import com.shenmazong.utils.ResultResponse;
import com.shenmazong.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2022/1/12 9:54
 */

@RestController
@RequestMapping(value = "/admin")
@Api(tags = {"管理员接口"})
public class TbAdminUserController {
    @Autowired
    TbAdminService tbAdminService;

    @ApiOperation(value="管理员用户登录", notes="根据用户名和密码进行登录", produces="application/json")
    @PostMapping(value = "/userLogin")
    public ResultResponse userLogin(@RequestBody LoginVo loginVo) {
        return tbAdminService.userLogin(loginVo);
    }

    @ApiOperation(value="管理员用户重置密码", notes="根据原密码对密码进行重置", produces="application/json")
    @PostMapping(value = "/userResetPassword")
    public ResultResponse userResetPassword(@RequestBody ResetPassworVo resetPassworVo) {
        return tbAdminService.userResetPassword(resetPassworVo);
    }

    @ApiOperation(value="管理员用户注册", notes="买家用户进行注册", produces="application/json")
    @PostMapping(value = "/addUser")
    public ResultResponse addUser(@RequestBody AddAdminVo addAdminVo) {
        return tbAdminService.addUser(addAdminVo);
    }

    @ApiOperation(value="发送验证码", notes="根据手机号发送验证码", produces="application/json")
    @PostMapping(value = "/sendCode")
    public ResultResponse sendCode(@RequestBody MobileVo mobileVo) {
        return tbAdminService.sendCode(mobileVo);
    }

    @ApiOperation(value="分页获取卖家信息", notes="分页获取卖家信息", produces="application/json")
    @PostMapping(value = "/getSellerByPage")
    public ResultResponse getSellerByPage(@RequestBody PageVo pageVo) {
        return tbAdminService.getSellerByPage(pageVo);
    }
}
